package aygx.spring.boot.principle.config;

import aygx.spring.boot.principle.entity.Dog;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;

/**
 * @author 暗影孤星
 * @date 2022/7/24 22:57
 * @description
 */
public class Component2Config {

    /**
     * OnClass 存在类
     * OnBean 注入bean
     */
    @Bean
    @ConditionalOnClass(name = "aygx.spring.boot.principle.entity.People")
    public Dog tom1() {
        return new Dog();
    }

    @Bean
    @ConditionalOnMissingClass("aygx.spring.boot.principle.entity.People")
    public Dog tom2() {
        return new Dog();
    }
}
